------------------ GiaoDich--------------
------------ thongtin giao dich ------------
if exists (select name from sysobjects where name like 'Proc_GiaoDich_GetById')
	drop procedure Proc_GiaoDich_GetById
go

create PROC Proc_GiaoDich_GetById (@maGD int )
as
	select * from GiaoDich
	where GiaoDich.MaGD = @maGD
go

Exec Proc_GiaoDich_GetById 1
go


select * from GiaoDich
------------------------------
-----------update giao dich-------------
if exists (select name from sysobjects where name like 'Proc_GiaoDich_Update')
	drop procedure Proc_GiaoDich_Update
go

create PROC Proc_GiaoDich_Update (@maGD int ,@maTKThe int ,@loaiGD int , @ngayGD datetime ,
	 @diaChi nvarchar (50), @soTienGD int , @noiDung nvarchar, @maTKNhan int, @maNganHang int, @maNV int, @trangThai int)
as
	
		Update GiaoDich 
		set MaTKThe= @maTKThe ,LoaiGD= @loaiGD, NgayGD= @ngayGD, DiaChiGD= @diaChi, SoTienGD=@soTienGD,
			NoiDungGD= @noiDung, MaTKNhan= @maTKNhan, MaNganHang= @maNganHang, MaNVGD=@maNV , TrangThaiGD=@trangThai
		where @maGD= MaGD 

go

------------------------------
-----------------Them giao dich----------------
if exists (select name from sysobjects where name like 'Proc_GiaoDich_Add')
	drop procedure Proc_GiaoDich_Add
go

create PROC Proc_GiaoDich_Add (@maTKThe int ,@loaiGD int , @ngayGD datetime ,
	 @diaChi nvarchar (50), @soTienGD int , @noiDung nvarchar, @maTKNhan int, @maNganHang int, @maNV int, @trangThai int)
as
	insert into GiaoDich(MaTKThe,LoaiGD,NgayGD,DiaChiGD,SoTienGD,MaTKNhan,NoiDungGD ,MaNganHang,MaNVGD,TrangThaiGD)
	values (@maTKThe  ,@loaiGD  , @ngayGD ,
	 @diaChi , @soTienGD  , @noiDung , @maTKNhan , @maNganHang , @maNV, @trangThai) 
go


select * from GiaoDich
go
